include "res.h"
#include "GD25Q128E_CMD.h"
#include "stdio.h"

#define ecg_measure_pic 0x0
#define spo2_measure_pic_addr     0x0000A8C4
#define temp_measure_pic_addr     0x00015188
//#define monitor_measure_pic_addr  0x0001FA4C
//#define history_measure_pic_addr  0x0002A310
//#define settings_measure_pic_addr 0x00034BD4


//#define inner_02_addr             0x0003F498
//#define outer_02_addr             0x00056C80
//#define spo2_inner_addr           0x0005F7BC
//#define spo2_outer_addr           0x00068778
//#define ttest_02_addr             0x000712B4

//#define bluetooth_03_addr         0x0008061E        
//#define ecg_03_addr               0x00085DD0
//#define usermod_03_addr           0x0008B480             
//#define sound_03_addr             0x00090B30              
//#define brightness_03_addr        0x000961E0             
//#define clear_03_addr             0x0009B890 
//#define language_03_addr          0x000A0F40             
//#define restore_03_addr           0x000A65F0              
//#define about_03_addr             0x000ABCA0 
//#define date_03_addr              0x000B1350 
//#define battery_00_addr      0x000B6A00
//#define battery_01_addr      0x000B8504              

//#define battery_02_addr      0x000BA008             

//#define battery_03_addr      0x000BBB0C              

//#define battery_04_addr      0x000BD610  


//#define base_02    (0xc0096000+pic_len*6)
//#define base_03    (base_02+pic_len_02+pic_len_0202*10+pic_len_03)//D5498
//#define base_04    (base_03+pic_len_04*14)

//#define base_05    (base_04+pic_len_06*9)
//#define base_06    (base_05+pic_len_07*2)

//#define base07  (base_06+pic_len_08*3+0x00003004+0x00001B04+0x00003004)
// 
//#define return_back_addr     0x000BF114 
//#define return_back_02_addr  0x000C0C18  
//#define warning_op_addr      0x000C271C               

//#define home_op_addr         0x000DA094 
//#define del_op_addr          0x000D49E4 
//#define play_op_addr         0x000CF334 

//#define adc_addr             0x000DF744
//#define dec_addr             0x000E2748
//          
//#define ecg_folder_addr      0x001C6750
//#define spo2_folder_addr     0x001D2754
//#define temp_folder_addr     0x001DE758

//#define monitor1_addr        0x001F3768
//#define monitor2_addr        0x001FC01C
//#define file_all_addr        0x001ED760

//#define indicator1_addr      0x0021AA14
//#define indicator2_addr      0x002FBA18



uint8_t mainpage0[MAIN_LEN] __attribute__((at(0x20018500+MAIN_LEN)));
          

uint8_t mainpage1[MAIN_LEN];// __attribute__((at(0x20038500+MAIN_LEN*2)));
uint8_t mainpage2[MAIN_LEN];// __attribute__((at(0x20038500+MAIN_LEN*3)));
uint8_t mainpage3[MAIN_LEN];// __attribute__((at(0x20038500+MAIN_LEN*4)));
uint8_t mainpage4[MAIN_LEN];// __attribute__((at(0x20038500+MAIN_LEN*5)));
uint8_t mainpage5[MAIN_LEN];// __attribute__((at(0x20038500+MAIN_LEN*6)));
//uint8_t inner_02[pic_len_02]       __attribute__((at(base_02+pic_len_02)));
//uint8_t outter_02[pic_len_0202]    __attribute__((at(base_02+pic_len_02*2+pic_len_0202)));
//uint8_t s_outter_02[pic_len_0202]  __attribute__((at(base_02+pic_len_02*2+pic_len_0202*3)));
//uint8_t s_inner_02[pic_len_0202]   __attribute__((at(base_02+pic_len_02*2+pic_len_0202*4)));
//uint8_t t_test_02[pic_len_03]      __attribute__((at(base_02+pic_len_02*2+pic_len_0202*5)));

//uint8_t bluetooth_03[pic_len_04]   __attribute__((at(base_03+pic_len_04)));
//uint8_t ecg_03[pic_len_04]         __attribute__((at(base_03+pic_len_04*2)));
//uint8_t usermode_03[pic_len_04]    __attribute__((at(base_03+pic_len_04*3)));
//uint8_t brightness_03[pic_len_04]  __attribute__((at(base_03+pic_len_04*4)));
//uint8_t sound_03[pic_len_04]       __attribute__((at(base_03+pic_len_04*5)));
//uint8_t date_03[pic_len_04]        __attribute__((at(base_03+pic_len_04*6)));
//uint8_t language_03[pic_len_04]    __attribute__((at(base_03+pic_len_04*7)));
//uint8_t clear_03[pic_len_04]       __attribute__((at(base_03+pic_len_04*8)));
//uint8_t restore_03[pic_len_04]     __attribute__((at(base_03+pic_len_04*9)));
//uint8_t about_03[pic_len_04]       __attribute__((at(base_03+pic_len_04*10)));
//uint8_t home_op[pic_len_04]        __attribute__((at(base_03+pic_len_04*11)));
//uint8_t del_op[pic_len_04]         __attribute__((at(base_03+pic_len_04*12)));
//uint8_t play_op[pic_len_04]        __attribute__((at(base_03+pic_len_04*13)));


//uint8_t warning_op[pic_len_06]               __attribute__((at(base_04+pic_len_06)));
//uint8_t return_back[pic_len_06]              __attribute__((at(base_04+pic_len_06*2)));
//uint8_t return_back_02[pic_len_06]           __attribute__((at(base_04+pic_len_06*3)));
//uint8_t battery_status[pic_len_06]           __attribute__((at(base_04+pic_len_06*4)));
//uint8_t battery_status1[pic_len_06]          __attribute__((at(base_04+pic_len_06*5)));
//uint8_t battery_status2[pic_len_06]          __attribute__((at(base_04+pic_len_06*6)));
//uint8_t battery_status3[pic_len_06]          __attribute__((at(base_04+pic_len_06*7)));
//uint8_t battery_status4[pic_len_06]          __attribute__((at(base_04+pic_len_06*8)));
//uint8_t adc_07[pic_len_07]                   __attribute__((at(base_05)));
//uint8_t dec_07[pic_len_07]                   __attribute__((at(base_05+pic_len_07)));
//uint8_t ui_ecg_folder[pic_len_08]            __attribute__((at(base_06)));
//uint8_t ui_spo2_folder[pic_len_08]           __attribute__((at(base_06+pic_len_08)));
//uint8_t ui_temp_folder[pic_len_08]           __attribute__((at(base_06+pic_len_08*2)));

//uint8_t ui_img_high[0x00003004]              __attribute__((at(base_06+pic_len_08*3)));
//uint8_t ui_img_low[0x00001B04]               __attribute__((at(base_06+pic_len_08*3+0x00003004)));
//uint8_t ui_img_replay[0x00003004]            __attribute__((at(base_06+pic_len_08*3+0x00003004+0x00001B04)));

//uint8_t img_monitor1_map[0x88B4]         __attribute__((at(base07)));
//uint8_t img_monitor2_map[0x88B4]         __attribute__((at(base07+0x88B4)));
//uint8_t file_all_map[0x0000C004]          __attribute__((at(base07+0x88B4*2)));
//uint8_t savetime_map[0x00004144]          __attribute__((at(base07+0x88B4*2+0x0000C004)));

//uint8_t indicator1_map[0x000E1004]        __attribute__((at(base07+0x88B4*2+0x0000C004+0x00004144+10240)));
//uint8_t indicator2_map[0x000E1004]        __attribute__((at(base07+0x88B4*2+0x0000C004+0x00004144+0x000E1004+10240)));


//void load_page1(void)
//{
//	flash_read(inner_02_addr,pic_len_02,inner_02);
////	flash_read(outer_02_addr,pic_len_02,outter_02);
//}
//void load_page2(void)
//{
//	flash_read(spo2_inner_addr,12265*3,s_inner_02);
//	flash_read(spo2_outer_addr,12265*3,s_outter_02);
//}
//void load_page3(void)
//{
//	flash_read(ttest_02_addr,pic_len_03,t_test_02);
//}
//void load_page4(void)
//{
//	flash_read(inner_02_addr,pic_len_02,inner_02);
//	flash_read(outer_02_addr,pic_len_02,outter_02);
//}

struct array{
uint32_t len;
uint32_t addr;
uint8_t  *array;
};
struct array my_array[]=
{
{MAIN_LEN,HEALTH_ADDR,mainpage0},
{MAIN_LEN,HEALTH_ADDR,mainpage1},
{MAIN_LEN,HEALTH_ADDR,mainpage2},
{MAIN_LEN,HEALTH_ADDR,mainpage3},
{MAIN_LEN,HEALTH_ADDR,mainpage4},
{MAIN_LEN,HEALTH_ADDR,mainpage5},

};
static bool sg_load_res_flag = false;
bool Get_load_res_flag(void)
{
	return sg_load_res_flag;
}
void load_res_toram(void)
{
	static int hhh=0;	
	static int max_num=sizeof(my_array)/sizeof(my_array[0]);
    if(hhh>=max_num)
	{
		sg_load_res_flag=true;
		return ;
	}
	else
	{	
		flash_read(my_array[hhh].addr,my_array[hhh].len,my_array[hhh].array);
		hhh++;
        printf("%s--%d--hhh:%d\r\n",__FUNCTION__,__LINE__,hhh);
	}
}